<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>sessionStorage</title>
</head>
<body>
    <div class="learn">
        <h1>sessionStorage用法</h1>
        
    </div>
</body>
<script>
if(window.sessionStorage) {
    alert("你的浏览器支持sessionStorage");


    //  方法一
    sessionStorage.setItem("name", "崔颢");
    let res1 = sessionStorage.getItem("name");
    alert(res1);
    

    // 方法二
    sessionStorage.name = "你好";
    let res2 = sessionStorage.name;
    alert(res2);

}else {
    alert("你的浏览器不支持sessionStorage");
}
</script>
</html>